
#include "dev_washer.h"
#include "page_base.h"
#include "img_common.h"
#include "pt_ipc.h"
#include "pt_fs.h"
#include "sys_font.h"
#include "com_api.h"

extern char *wk_sta_str[11];
static  char * icon_stat[5] =
{
	"Power3_Default.png",  //pwe_dft
    "Power3_Selected.png", //pwr
    "Start_Default.png",   //start
	"Pause_Default.png",   //pause
	"Cancel_Default.png",   //stop cancel
};

/*****************dev control**************** */
static void update_widget(dev_washer_t *dev);
static int dev_washer_ctl_http(dev_washer_t* dev)
{
	washer_http_req_t req;

    memset(&req,0,sizeof(washer_http_req_t));

	req.ctl_sta = dev->data.ctl.ctl_state;

	req.version = dev->data.state.version;
   
    snprintf(req.devid,sizeof(req.devid),"%s",dev->data.base.devid);

	snprintf(req.mode,sizeof(req.mode),"%s",dev->data.state.mode);

    // pt_ipc_send_msg(KH_WASHER_CTRL,(void*)&req,sizeof(washer_http_req_t));

	return 0;
}


const char *wash_main_stage_str[6] = {"","","预约中","洗涤中","烘干中","保管中"};
/*预洗、主洗、漂洗、干燥，结束 */ //1,2,3,4,5
const char *wash_stage_str[6] = {"","预洗 | ","主洗 | ","漂洗 | ","干燥 | ",""};
const char *wk_page_str[4] = {"DEV_WORK","DEV_OFF","DEV_OFF_LINE","DEV_ERROR","DEV_INVALID"};
const char *ui_stage_str[14] = {"关机中","待机中","预约中","洗涤中","烘干中","保管中","洗涤中_spec","dialog","未关门","洗涤暂停","故障中","离线中","",""};

void pt_washer_state(dev_washer_t  *dev)
{
	debug_d("washer_devid:%s [%d %d %d] status:%s work_state:%s ui_state:%s door:%d\n",
	dev->data.base.devid,	
	dev->data.state.status,
	dev->data.state.work_state,
	dev->ui.ui_para.ui_stat,
	wk_page_str[dev->data.state.status],
	// wk_sta_str[dev->data.state.work_state],
	ui_stage_str[dev->ui.ui_para.ui_stat],
	dev->data.state.door_state);
}

static void set_left_time(dev_washer_t *dev) 
{
	if(dev->data.state.door_state)
		return;
	int left_time = 0;
	int idx = 0;
	//midea_ui_safe_set_text(dev->ui.label_info, wash_main_stage_str[state]);
	switch(dev->data.state.work_state)
	{
		case WASHER_STAT_WORK://3
		case WASHER_STAT_PAUSE:
			 left_time = dev->data.state.run_left_time;
			 if(dev->data.state.wash_stage > 5)
			 {
				debug_d("wash_stage data err:%d\n",dev->data.state.wash_stage);
				return;
			 }
			 idx = dev->data.state.wash_stage;
			 break;
		case WASHER_STAT_ORDER: //2
			left_time = dev->data.state.order_left_time;
			break;
		case WASHER_STAT_DRYING://4
			left_time = dev->data.state.dry_left_time;
			break;
		case WASHER_STAT_KEEPING://5
			left_time = dev->data.state.keep_left_time;
			break;
		default:
			return;
	}
	#ifdef PROACTIVELY_UPDATE_UI
	if(!dev->data.stactl.got_data)
	{
		debug_d("got_data--0\n");
		midea_ui_safe_add_flag(dev->ui.label_info2,LV_OBJ_FLAG_HIDDEN);
		return;
	}
	else
	{
		debug_d("got_data--1\n");
		//dev->data.stactl.got_data = 0;
		midea_ui_safe_clear_flag(dev->ui.label_info2,LV_OBJ_FLAG_HIDDEN);
	}
	#endif
	char str[64] = {0};
	if(dev->data.state.work_state == WASHER_STAT_KEEPING)
	{
		// if(dev->data.state.version == 1) //v1.0
		// 	sprintf(str, "剩余时长: %d 小时",left_time);
		// else //v 2.0
		// 	sprintf(str, "剩余时长: %d 分钟",left_time);
		sprintf(str, "剩余时长: %d 小时",left_time);
	}
	else
	{
		int h = left_time/60;
		int m = left_time - h * 60;

		if(h > 0)
		{
			sprintf(str, "%s剩余时长: %d 时 %d 分",wash_stage_str[idx], h,m);
		}
		else
		{
			m = left_time;//== 0 ? 1:left_time;
			sprintf(str, "%s剩余时长: %d 分", wash_stage_str[idx],m);
		}
	}
	//debug_d("set_data :%d\n",left_time);
	midea_ui_safe_set_text(dev->ui.label_info2, str);
}

static void show_spe_data(dev_washer_t *dev)
{
	//static uint8_t dat_num = 0xff;
	char str[16];
	int h,m,cur_dat_num;
	if(dev->data.state.run_left_time  > 60)
	{
		h = dev->data.state.run_left_time / 60;
		m = dev->data.state.run_left_time - h * 60;
	}
	else
	{
		h = 0;
		m = dev->data.state.run_left_time;
	}
	if(h == 0)
	{
		cur_dat_num = 1;
		sprintf(str, "%d",m);
		midea_ui_safe_set_text(dev->ui.lbl_data2, str);
	}
	else
	{
		cur_dat_num = 2;
		sprintf(str, "%d",h);
		midea_ui_safe_set_text(dev->ui.lbl_data1, str);
		memset(str,0,sizeof(str));
		sprintf(str, "%d",m);
		midea_ui_safe_set_text(dev->ui.lbl_data2, str);
	}
	// if(dev->ui.ui_para.init_work_time == 0)
	// {
	// 	printf("init_work_time data error\n");
	// 	return;
	// }
	//debug_d("------special data num:%d,%d\n",dat_num , cur_dat_num);
	//if(dat_num != cur_dat_num)
	{
		//dat_num = cur_dat_num;
		if(cur_dat_num == 1)
		{
			lv_obj_set_pos(dev->ui.lbl_data2, 110, 52);
			lv_obj_set_pos(dev->ui.lbl_unit2, 250, 118);
			midea_ui_safe_add_flag(dev->ui.lbl_data1, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_add_flag(dev->ui.lbl_unit1, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_clear_flag(dev->ui.lbl_data2, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_clear_flag(dev->ui.lbl_unit2, LV_OBJ_FLAG_HIDDEN);//
		}
		else if(cur_dat_num == 2)
		{
			midea_ui_safe_clear_flag(dev->ui.lbl_data1, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_clear_flag(dev->ui.lbl_data2, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_clear_flag(dev->ui.lbl_unit1, LV_OBJ_FLAG_HIDDEN);//
			midea_ui_safe_clear_flag(dev->ui.lbl_unit2, LV_OBJ_FLAG_HIDDEN);//
			lv_obj_set_pos(dev->ui.lbl_data1, 38, 52);
			lv_obj_set_pos(dev->ui.lbl_data2, 168, 52);
			lv_obj_set_pos(dev->ui.lbl_unit1, 150, 118);
			lv_obj_set_pos(dev->ui.lbl_unit2, 304, 118);
		}
	}
	//if(dev->ui.ui_para.init_work_time != 0)
	if(dev->ui.ui_para.init_work_time  < dev->data.state.run_left_time)
	{
		dev->ui.ui_para.init_work_time  = dev->data.state.run_left_time;
		//debug_d("2==init_work_time:%d\n",dev->ui.ui_para.init_work_time);
	}
	if(dev->ui.ui_para.init_work_time == 0)
	{
		debug_d("init_work_time err\n");
		return;
	}
	dev->ui.ui_para.bar_value = (dev->ui.ui_para.init_work_time - dev->data.state.run_left_time) * 100 / dev->ui.ui_para.init_work_time;
	//dev->ui.ui_para.bar_value = 50;
	lv_bar_set_value(dev->ui.bar_1, dev->ui.ui_para.bar_value, LV_ANIM_OFF);
	//debug_d("washer bar:%d %d\n",dev->ui.ui_para.init_work_time,dev->data.state.run_left_time);
}

static void specai_info_show(dev_washer_t *dev,bool show)
{
	if(show)
	{
		midea_ui_safe_clear_flag(dev->ui.cont_spec_mode, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.lbl_info, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.lbl_unit1, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.lbl_unit2, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.lbl_data1, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.lbl_data2, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.bar_1, LV_OBJ_FLAG_HIDDEN);
	}
	else
	{
		midea_ui_safe_add_flag(dev->ui.cont_spec_mode, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.lbl_info, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.lbl_unit1, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.lbl_unit2, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.lbl_data1, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.lbl_data2, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.bar_1, LV_OBJ_FLAG_HIDDEN);
	}
}

static void dialog_show(dev_washer_t *dev,bool show)
{
	if(show)
	{
		midea_ui_safe_clear_flag(dev->ui.cont_dialog, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.btn_gotit, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.img_ok, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.label_note, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.label_sec, LV_OBJ_FLAG_HIDDEN);
	}
	else
	{
		midea_ui_safe_add_flag(dev->ui.cont_dialog, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.btn_gotit, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.img_ok, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.label_note, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.label_sec, LV_OBJ_FLAG_HIDDEN);
	}
}

static void special_stege_show(dev_washer_t *dev,uint8_t stage)
{
	if(stage == 0) //hide all special widgets
	{
		debug_d("stage 0: hide special info and dialog--------------------\n");
		specai_info_show(dev,false);
		dialog_show(dev,false);
	}
	else if(stage == 1) 
	{
		debug_d("stage 1: show special info and hide dialog--------------------\n");
		//dev->ui.ui_para.in_spec_mod = 1;
		//TODO:关闭熄屏功能，除非在睡眠模式
		specai_info_show(dev,true);
		dialog_show(dev,false);
		show_spe_data(dev);
	}
	else if(stage == 2)
	{
		debug_d("stage 2 hide special info and show dialog--------------------\n");
		specai_info_show(dev,false);
		dialog_show(dev,true);
	}
}

static void switch_normal_special(dev_washer_t *dev,int normal_state,uint8_t opt)
{
	if(opt > 2)
	return;
	if(normal_state == 1) //normal mode
	{
		debug_d("washer normal mode show %d btn:%d----\n",opt);
		//hide special mode widgets	
		special_stege_show(dev,0);

		//normal mode
		midea_ui_safe_clear_flag(dev->ui.label_info, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_clear_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN);
		if(opt == 1) //btn cnt == 1
		{
			midea_ui_safe_clear_flag(dev->ui.l_btn, LV_OBJ_FLAG_HIDDEN);
			midea_ui_safe_add_flag(dev->ui.r_btn, LV_OBJ_FLAG_HIDDEN);
			lv_obj_set_pos(dev->ui.l_btn,191,195);
		}
		else //btn cnt == 2
		{
			midea_ui_safe_clear_flag(dev->ui.l_btn, LV_OBJ_FLAG_HIDDEN);
			midea_ui_safe_clear_flag(dev->ui.r_btn, LV_OBJ_FLAG_HIDDEN);
			lv_obj_set_pos(dev->ui.l_btn,80,195);
			lv_obj_set_pos(dev->ui.r_btn,286,195);
		}
	}
	else //special mode
	{
		debug_d("washer special mode step:%d----\n",opt);
		//hide normal mode widgets
		midea_ui_safe_add_flag(dev->ui.label_info, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.l_btn, LV_OBJ_FLAG_HIDDEN);
		midea_ui_safe_add_flag(dev->ui.r_btn, LV_OBJ_FLAG_HIDDEN);

		special_stege_show(dev,opt);
	}

}

static void play_wash_done_voice()
{
		//语音提示
	char play_tone = 61; //*61*/  "洗碗机洗涤完成啦",
	// pt_ipc_send_msg(IPC_PLAY_TONE,(char*)(&play_tone),1);
}

static int update_ct_sec(dev_washer_t *dev)
{
	if(dev->ui.ui_para.ui_stat != wh_ui_stat_dialog)
		return -1;
    char buf[2];
	//if(dev->ui.ui_para.ct_sec % WH_SEC_CNT == 0)
	{
		sprintf(buf,  "%d" , dev->ui.ui_para.ct_sec);
		lv_label_set_text(dev->ui.label_sec, buf);
	}
	
    if(dev->ui.ui_para.ct_sec >= 1)
    {
		dev->ui.ui_para.ct_sec--;
		if(dev->ui.ui_para.ct_sec == 0)
		{
			// if(dev->data.state.work_state == WASHER_STAT_POWER_OFF)
			// {
			// 	dev->data.state.status = DEV_OFF;
			// }
			// else
			// {
			// 	if( dev->data.state.work_state == WASHER_STAT_STANDBY
			// 		|| dev->data.state.work_state == WASHER_STAT_ORDER
			// 		|| dev->data.state.work_state == WASHER_STAT_WORK
			// 		|| dev->data.state.work_state == WASHER_STAT_DRYING
			// 		|| dev->data.state.work_state == WASHER_STAT_KEEPING
			// 		)
			// 	{
			// 		dev->data.state.status = DEV_WORK;
			// 	}
			// }
			
			
			dev->ui.ui_para.ui_stat = wh_ui_stat_invalid;
			return -1;
		}
    }
	return 0;
}

int get_cur_page_state(dev_washer_t *dev)
{
	switch(dev->ui.ui_para.ui_stat)
	{
		case wh_ui_stat_power_off:
			return DEV_OFF;
		case wh_ui_stat_standby: //待机
		case wh_ui_stat_order://预约中
		case wh_ui_stat_work: //洗涤中
		case wh_ui_stat_dry://烘干中
		case wh_ui_stat_keep: //保管
		case wh_ui_stat_spec_work: //特殊工作状态-洗涤中
		case wh_ui_stat_door_open:
		case wh_ui_stat_pause:
			return DEV_WORK;
		case wh_ui_stat_error:
			return 0;
		case wh_ui_stat_off_line:
			return DEV_OFF_LINE;
		case wh_ui_stat_invalid:
		case wh_ui_stat_dialog:	//dialog
			return 0;
		default:
			return 0;
	}
}

static void update_page(dev_washer_t* dev)
{
	//if(DEV_WASHER != kh_dev_type_get())
	//	return ;
	if(dev->ui.ui_para.ui_stat == wh_ui_stat_dialog)
	{
		debug_d("page not update\n:%s",ui_stage_str[dev->ui.ui_para.ui_stat]);
		return ;
	}
		

	dev->ui.ui_para.tick = 0;
    switch(dev->data.state.status)
	{
    case DEV_WORK:
    {
		//washer_stat_proc(dev);
		//lv_timer_resume(dev->ui.timer);
		debug_d("page in:%s\n",wk_page_str[dev->data.state.status]);
        ui_dev_off_hide(&dev->ui.dev_off);
        ui_dev_off_line_hide(&dev->ui.dev_off_line);
		ui_dev_washer_show(dev);
		#ifdef USE_ERR_PAGE
		ui_dev_err_e2_hide(&dev->ui.dev_e2);
		#endif
        break;
    }
    case DEV_OFF:
    {
		debug_d("page in:%s\n",wk_page_str[dev->data.state.status]);
        ui_dev_washer_hide(dev);
		//lv_timer_pause(dev->ui.timer);
        ui_dev_off_show(&dev->ui.dev_off);
        ui_dev_off_line_hide(&dev->ui.dev_off_line);
		#ifdef USE_ERR_PAGE
		ui_dev_err_e2_hide(&dev->ui.dev_e2);
		#endif
        break;
    }
    case DEV_OFF_LINE:
    {
		debug_d("page in:%s\n",wk_page_str[dev->data.state.status]);
        ui_dev_washer_hide(dev);
		//washer_stat_proc(dev);
		//lv_timer_pause(dev->ui.timer);
        ui_dev_off_hide(&dev->ui.dev_off);
        ui_dev_off_line_show(&dev->ui.dev_off_line);
		#ifdef USE_ERR_PAGE
		ui_dev_err_e2_hide(&dev->ui.dev_e2);
		#endif
        break;
    }
	case 33:
    {
		debug_d("page in:%s\n",wk_page_str[dev->data.state.status]);
		#ifndef USE_ERR_PAGE
		ui_dev_washer_show(dev);
		//washer_stat_proc(dev);
		//lv_timer_resume(dev->ui.timer);
        ui_dev_off_hide(&dev->ui.dev_off);
        ui_dev_off_line_hide(&dev->ui.dev_off_line);
		#ifdef USE_ERR_PAGE
		ui_dev_err_e2_hide(&dev->ui.dev_e2);
		#endif
		 #else
		switch(dev->data.state.err_code)
		{
			case 1: //E1
				ui_dev_washer_show(dev);
				washer_stat_proc(dev);
				lv_timer_resume(dev->ui.timer);
				ui_dev_off_hide(&dev->ui.dev_off);
				ui_dev_off_line_hide(&dev->ui.dev_off_line);
				ui_dev_err_e2_hide(&dev->ui.dev_e2);

				// if(pt_dev_type_get() == DEV_TYPE_WASHER)
				// {
				// 	pop_win_load("msg_e1",lv_page_msg_e1_create());
				// }
				break;
			case 2: //E2
				ui_dev_washer_hide(dev);
				lv_timer_pause(dev->ui.timer);
				ui_dev_off_hide(&dev->ui.dev_off);
				ui_dev_off_line_hide(&dev->ui.dev_off_line);
				ui_dev_err_e2_show(&dev->ui.dev_e2);
				break;
			default:
				break;
		}
		#endif

        break;

    }
	default:break;
	}
}

static void update_widget(dev_washer_t *dev)
{
	if(dev->ui.ui_para.ui_stat == dev->ui.ui_para.ui_last_stat)
		return;
	dev->ui.ui_para.ui_last_stat = dev->ui.ui_para.ui_stat;	
	debug_d("washer ui stage:%d %s\n",dev->ui.ui_para.ui_stat,ui_stage_str[dev->ui.ui_para.ui_stat]);
	switch(dev->ui.ui_para.ui_stat)
	{
		case wh_ui_stat_power_off:
		case wh_ui_stat_off_line:
			dev->ui.ui_para.init_work_time = 0;
			//debug_d("3==init_work_time:%d\n",dev->ui.ui_para.init_work_time);
			midea_ui_safe_add_flag(dev->ui.label_info, LV_OBJ_FLAG_HIDDEN);
			midea_ui_safe_add_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN);
			midea_ui_safe_add_flag(dev->ui.l_btn, LV_OBJ_FLAG_HIDDEN);
			midea_ui_safe_add_flag(dev->ui.r_btn, LV_OBJ_FLAG_HIDDEN);
			special_stege_show(dev,0); //0:hide all spec widgets
			break;
		case wh_ui_stat_standby: //待机
			dev->ui.ui_para.init_work_time = 0;
			//debug_d("4==init_work_time:%d\n",dev->ui.ui_para.init_work_time);
			dev->ui.ui_para.in_spec_mod = 0;
			switch_normal_special(dev,1,2);
			midea_ui_safe_set_text(dev->ui.label_info, "待机中");
			midea_ui_safe_add_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //no show left time info
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[0])); //pwr
			midea_ui_set_img_src(dev->ui.r_btn_img,pt_fs_get(icon_stat[2])); //start
			break;
		case wh_ui_stat_order://预约中
			dev->ui.ui_para.init_work_time = 0;
			//debug_d("5==init_work_time:%d\n",dev->ui.ui_para.init_work_time);
			switch_normal_special(dev,1,1);
			midea_ui_safe_set_text(dev->ui.label_info, "预约中");
			midea_ui_safe_clear_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //show left time info
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[4])); //stop
			break;
		case wh_ui_stat_work: //洗涤中
			switch_normal_special(dev,1,2);
			midea_ui_safe_set_text(dev->ui.label_info, "洗涤中");
			midea_ui_safe_clear_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //show left time info
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[3])); //pause
			midea_ui_set_img_src(dev->ui.r_btn_img,pt_fs_get(icon_stat[4])); //stop
			break;
		case wh_ui_stat_dry://烘干中
			switch_normal_special(dev,1,1);
			midea_ui_safe_set_text(dev->ui.label_info, "烘干中");
			midea_ui_safe_clear_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //show left time info
			//midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[3])); //pause
			//midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[0])); //pwr
			//midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[1])); //pwr select
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[4])); //stop

			break;
		case wh_ui_stat_keep: //保管
			switch_normal_special(dev,1,1);
			midea_ui_safe_set_text(dev->ui.label_info, "保管中");
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[4])); //stop
			break;
		case wh_ui_stat_spec_work: //特殊工作状态-洗涤中
			switch_normal_special(dev,0,1);
			break;
		case wh_ui_stat_dialog:	//dialog
			dev->ui.ui_para.ct_sec = 10; //倒计时6s
			switch_normal_special(dev,0,2);
			break;
		case wh_ui_stat_door_open:
			switch_normal_special(dev,1,1);
			midea_ui_safe_set_text(dev->ui.label_info, "未关门");
			midea_ui_safe_add_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //no show left time info
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[0])); //pwr
			//debug_d("do_door_open\n");
			break;
		case wh_ui_stat_pause:
			debug_d("----ui in pause mode----\n");
			switch_normal_special(dev,1,2);
			midea_ui_safe_set_text(dev->ui.label_info, "洗涤中");
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[2])); //start
			midea_ui_set_img_src(dev->ui.r_btn_img,pt_fs_get(icon_stat[4])); //stop
			break;
		case wh_ui_stat_error:
			switch_normal_special(dev,1,1);
			midea_ui_safe_set_text(dev->ui.label_info, "故障中");
			midea_ui_safe_add_flag(dev->ui.label_info2, LV_OBJ_FLAG_HIDDEN); //no show left time info
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[0])); //pwr
			break;
		default:
			break;
	}
}

int spec_flag_proc(dev_washer_t *dev)
{
	int rlt = -1;
	switch(dev->data.stactl.spe_flag)
	{
		case 1: //washing done
			//dev->data.state.work_state = WASHER_STAT_STANDBY;
			//dev->data.state.status = DEV_WORK;
			dev->ui.ui_para.ui_stat = wh_ui_stat_dialog;
			dev->data.stactl.spe_flag = 0;
			dev->ui.ui_para.washing = 0;
			update_widget(dev);
			play_wash_done_voice();
			// root_set_status(SYS_STATUS_NORMAL);
			rlt = 0;
			break;
		case 2: //cancel
			dev->data.state.work_state = WASHER_STAT_STANDBY;
			dev->data.state.status = DEV_WORK;
			dev->ui.ui_para.ui_stat = wh_ui_stat_standby;
			dev->data.stactl.spe_flag = 0;

			update_widget(dev);
			rlt = 0;
			break;
		default:
			rlt = -1;
			break;
	}
	return rlt;
}

//更新页面数据
static void update_data(dev_washer_t *dev,uint8_t en_lock)
{
	if(dev->ui.ui_para.locked && en_lock)
		return;
	//static uint8_t last_page = 0xff;
	if(spec_flag_proc(dev) == 0)
		return;
	//debug_d("test_2---\n");
	if(0 == update_ct_sec(dev))
		return;
	//debug_d("test_3---\n");
	if(get_cur_page_state(dev) != dev->data.state.status)
	{
		debug_d("---update_page:%d %d\n",dev->data.state.status,dev->data.state.work_state);
		//debug_d("---update_page:%d %d %s\n",last_page,dev->data.state.status,wk_page_str[dev->data.state.status]);
		update_page(dev);
	}

	switch(dev->data.state.work_state)
	{
		case WASHER_STAT_POWER_OFF:
			if(dev->ui.ui_para.ui_stat != wh_ui_stat_power_off)
			{
				dev->ui.ui_para.ui_stat = wh_ui_stat_power_off;
				update_widget(dev);
			}
			break;
		case WASHER_STAT_STANDBY://待机
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_standby)
			{
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_standby;
				update_widget(dev);
			}
			break;
		// case WASHER_STAT_DOOR_OPEN://未关门
		// 	if(dev->ui.ui_para.ui_stat != wh_ui_stat_door_open)
		// 	{
		// 		dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
		// 		update_widget(dev);
		// 	}
		// 	break;
		case WASHER_STAT_ORDER://预约中
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_order)
			{
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_order;
				update_widget(dev);
			}
			set_left_time(dev);
			break;
		case WASHER_STAT_WORK: //洗涤中
			// root_set_status(SYS_STATUS_SPECIAL);
			if(dev->ui.ui_para.washing == 0 && dev->data.state.wash_stage > 0)
			{
				dev->ui.ui_para.washing = 1;
				//获取总剩余时间
				if(dev->data.state.run_left_time > 0)
				{
					dev->ui.ui_para.init_work_time = dev->data.state.run_left_time;
					//debug_d("1==init_work_time:%d\n",dev->ui.ui_para.init_work_time);
					debug_d("===============init bar balue:%d================\n",dev->ui.ui_para.init_work_time);
				}
			}
			if(dev->ui.ui_para.ui_stat != wh_ui_stat_work && dev->ui.ui_para.ui_stat != wh_ui_stat_spec_work)
			{
				dev->ui.ui_para.state_tick = 0;
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_work;
				update_widget(dev);

				set_left_time(dev);
			}
			else
			{
				if(dev->ui.ui_para.ui_stat == wh_ui_stat_work)
				{
					if(dev->ui.ui_para.state_tick >= WASHER_TO_SPEC_WAIT_TIME
					&& dev->data.stactl.got_data )
					{
						if(dev->data.state.door_state)
						{
							dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
							update_widget(dev);
						}
						else
						{
							dev->ui.ui_para.ui_stat = wh_ui_stat_spec_work;
							dev->ui.ui_para.in_spec_mod = 1;
							update_widget(dev);
							show_spe_data(dev);
							//root_set_status(SYS_STATUS_SPECIAL);
							debug_d("time to switch special work mode------\n");
						}
					}
					else
					{
						set_left_time(dev);
					}
					
				}
				else if(dev->ui.ui_para.ui_stat == wh_ui_stat_spec_work)
				{
					show_spe_data(dev);
				}
			}
			break;
		case WASHER_STAT_DRYING://烘干中
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_dry)
			{
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_dry;
				update_widget(dev);
			}
			set_left_time(dev);
			break;
		case WASHER_STAT_KEEPING:  //保管中
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_keep)
			{
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_keep;
				update_widget(dev);
			}
			set_left_time(dev);
			break;
		case WASHER_STAT_PAUSE://
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_pause)
			{
				if(dev->data.state.door_state)
					dev->ui.ui_para.ui_stat = wh_ui_stat_door_open;
				else
					dev->ui.ui_para.ui_stat = wh_ui_stat_pause;
				update_widget(dev);
			}
			set_left_time(dev);
			break;
		case WASHER_STAT_ERROR://待机
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_error)
			{
				dev->ui.ui_para.ui_stat = wh_ui_stat_error;
				update_widget(dev);
			}
			break;
		case WASHER_STAT_OFFLINE:
			//if(dev->ui.ui_para.ui_stat != wh_ui_stat_off_line)
			{
				dev->ui.ui_para.ui_stat = wh_ui_stat_off_line;
				update_widget(dev);
			}
			break;
		default:
			break;
	}

}

static void scr_dev_washer_event_handler (lv_event_t *e)
{
	dev_washer_t* dev = NULL;
    dev = (dev_washer_t*)lv_event_get_user_data(e);
    //lv_event_code_t code = lv_event_get_code(e);

    if(e->code == LV_EVENT_GESTURE)
    {
        //debug_d("get sture\n");
        lv_indev_wait_release(lv_indev_get_act());

        lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
        switch(dir){
        case LV_DIR_LEFT:
            //debug_d("to left  ----to purifier page\n");
            break;
        case LV_DIR_RIGHT:
            //debug_d("to right -------to washer page\n");

            break;
		case LV_DIR_TOP:
			debug_d("getsture top:workstate:%d special:%d\n",dev->data.state.work_state,dev->ui.ui_para.in_spec_mod);
			if(dev->data.state.work_state == WASHER_STAT_WORK)
			{
				if(dev->ui.ui_para.in_spec_mod)
				{
					debug_d("switch normal work mode------\n");
					dev->ui.ui_para.in_spec_mod = 0;//
					dev->ui.ui_para.ui_stat = wh_ui_stat_work;
					dev->ui.ui_para.state_tick = 0;
					update_widget(dev);
					// root_set_status(SYS_STATUS_NORMAL);
				}
				else
				{
					debug_d("switch special work mode-----\n");
					dev->ui.ui_para.in_spec_mod = 1;
					dev->ui.ui_para.state_tick = 0;
					dev->ui.ui_para.ui_stat = wh_ui_stat_spec_work;
					update_widget(dev);
					//root_set_status(SYS_STATUS_SPECIAL);
					//uint8_t spec_mask = get_hi_pri_spec_mode(DEV_HEATER_DR);
					// if(spec_mask)
					// {
					// 	dev->ui.ui_para.in_spec_mod = 1;
					// 	update_ui(dev);
					// }
				}
			}
            break;
        case LV_DIR_BOTTOM:
            debug_d("------------------to bottom\n");
			//update_ui(1);
			// page_install("dev_rangehood", lv_page_dev_rangehood_create());
            // page_push_anim("dev_rangehood",LOAD_ANIM_MOVE_RIGHT);
            break;
        }
    }
}

void init_click_delay(dev_washer_t* dev)
{
	dev->ui.ui_para.locked = 1;
	dev->ui.ui_para.lock_tick = 0;
	debug_d("lock btn-----\n");
}

int is_btn_lock(dev_washer_t* dev)
{
	return dev->ui.ui_para.locked;
}
//power button event
static int dev_wh_l_btn_touch_released(lv_event_t* event,dev_washer_t* dev)
{
	dev->ui.ui_para.tick = 0;

	lv_area_t   t_area;
    lv_point_t  lv_point;
    lv_indev_t* indev  = NULL;
    lv_obj_t*   target = NULL;

    target = lv_event_get_target(event);
    if(!target){
        debug_e("err\n");
        return -1;
    }

    indev = lv_indev_get_act();
    if(!indev){
        return -1;
    }

    lv_indev_get_point(indev, &lv_point);
    lv_obj_get_coords(target, &t_area);

    if(!is_touch_in_target(&lv_point,&t_area)){
        debug_e("out range\n");
        return -1;
    }

	if(!pt_network_get()){
		debug_e("net err\n");
        return -1;
	}
	// if(dev->ui.ui_para.locked)
	// {
	// 	debug_d("l_btn invalid:%d\n",dev->ui.ui_para.lock_tick);
	// 	return -1;
	// }
	if(wh_ui_stat_door_open == dev->ui.ui_para.ui_stat)
	{
	  dev->data.state.work_state = WASHER_STAT_STANDBY;  //门开时按左键关机
	}
	printf("l_btn-----work_stat:%d\n",dev->data.state.work_state);
	#if 1
	switch(dev->data.state.work_state)
	{
		case WASHER_STAT_STANDBY:// 待机
		//case WASHER_STAT_DOOR_OPEN://未关门
		case WASHER_STAT_ERROR://故障中
		#ifdef PROACTIVELY_UPDATE_UI
			dev->data.state.work_state = WASHER_STAT_POWER_OFF;
			dev->data.state.status = DEV_OFF;
			update_data(dev,0);
			init_click_delay(dev);
		#endif
			//send http req
			dev->data.ctl.ctl_state = WASHING_CTL_POWER_OFF;
			dev_washer_ctl_http(dev);
			break;
		case WASHER_STAT_ORDER://2 预约中
			if(dev->data.state.lock == 0)
			{
				#ifdef PROACTIVELY_UPDATE_UI
				dev->data.state.work_state = WASHER_STAT_STANDBY;
				dev->data.state.status = DEV_WORK;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_ORDER_CANCLE;
				dev_washer_ctl_http(dev);
			}
			else
				debug_d("washer lock on can not cancle\n");
			break;
		case WASHER_STAT_WORK: //3 洗涤中
			if(dev->data.state.lock == 0)
			{
				#ifdef PROACTIVELY_UPDATE_UI
				dev->ui.last_stat = dev->data.state.work_state;
				dev->data.state.work_state = WASHER_STAT_PAUSE;
				dev->data.state.status = DEV_WORK;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_PAUSE;
				dev_washer_ctl_http(dev);
			}
			else
				debug_d("washer lock on can not pause\n");
			break;
		case WASHER_STAT_DRYING://4 烘干中
			if(dev->data.state.lock == 0)
			{
				#ifdef PROACTIVELY_UPDATE_UI
				dev->ui.last_stat = dev->data.state.work_state;
				dev->data.state.work_state = WASHER_STAT_POWER_OFF;
				dev->data.state.status = DEV_OFF;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_POWER_OFF;
				dev_washer_ctl_http(dev);
			}
			else
				debug_d("washer lock on can not cancle dry\n");
			break;
		case WASHER_STAT_KEEPING:  //5 保管中
			if(dev->data.state.lock == 0)
			{
				#ifdef PROACTIVELY_UPDATE_UI
				dev->ui.last_stat = dev->data.state.work_state;
				dev->data.state.work_state = WASHER_STAT_POWER_OFF;
				dev->data.state.status = DEV_OFF;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_KEEP_CANCLE;
				dev_washer_ctl_http(dev);
			}
			else
				debug_d("washer lock on can not cancle keeping\n");
			break;
		case WASHER_STAT_PAUSE: //
			#ifdef PROACTIVELY_UPDATE_UI
			midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[3])); //pause
			dev->data.state.work_state = WASHER_STAT_WORK;//dev->ui.last_stat;
			dev->data.state.status = DEV_WORK;
			dev->ui.ui_para.state_tick = 0;
			dev->ui.ui_para.ui_stat = wh_ui_stat_work;
			printf("cur_state:%d\n",dev->ui.last_stat);
			//update_data(dev,0);
			init_click_delay(dev);
			#endif
			//send http req
			dev->data.ctl.ctl_state = WASHING_CTL_RESUME;
			dev_washer_ctl_http(dev);
			break;

		case WASHER_STAT_OFFLINE:
			init_click_delay(dev);
			break;
		default:
			break;
	}
	#endif
    return 0;
}
#if 1 //
static void l_btn_event_cb(lv_event_t* event)
{
	dev_washer_t* dev = NULL;
    dev = (dev_washer_t*)lv_event_get_user_data(event);

    switch(event->code){
    case LV_EVENT_RELEASED:
    {
		dev_wh_l_btn_touch_released(event,dev);
		break;
    }
	default:break;
	}
}
#endif

static int dev_wh_r_btn_touch_released(lv_event_t* event,dev_washer_t* dev)
{
	dev->ui.ui_para.tick = 0;

	lv_area_t   t_area;
    lv_point_t  lv_point;
    lv_indev_t* indev  = NULL;
    lv_obj_t*   target = NULL;

    target = lv_event_get_target(event);
    if(!target){
        debug_e("err\n");
        return -1;
    }

    indev = lv_indev_get_act();
    if(!indev){
        return -1;
    }

    lv_indev_get_point(indev, &lv_point);
    lv_obj_get_coords(target, &t_area);

    if(!is_touch_in_target(&lv_point,&t_area)){
        debug_e("out range\n");
        return -1;
    }

	if(!pt_network_get()){
		debug_e("net err\n");
        return -1;
	}
	// if(dev->ui.ui_para.locked)
	// {
	// 	debug_d("r_btn invalid:%d\n",dev->ui.ui_para.lock_tick);
	// 	return -1;
	// }
	debug_d("r_btn----- work_stat:%d\n",dev->data.state.work_state);
	#if 1
	switch(dev->data.state.work_state)
	{
		case WASHER_STAT_STANDBY://0 待机
			if(dev->data.state.lock == 0)
			{
				#ifdef PROACTIVELY_UPDATE_UI
				dev->data.state.work_state = WASHER_STAT_WORK;
				dev->data.state.status = DEV_WORK;
				dev->data.stactl.got_data = 0;
				dev->data.state.wash_stage = 0;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_START;
				dev_washer_ctl_http(dev);
			}
			else
				debug_d("washer lock on can not start\n");
			break;
		case WASHER_STAT_WORK: //3 洗涤中
		case WASHER_STAT_PAUSE: //
			if(dev->data.state.lock == 0)
			{
				debug_d("washing cancle\n");
				#ifdef PROACTIVELY_UPDATE_UI
				dev->data.state.work_state = WASHER_STAT_WORK;
				dev->data.state.status = DEV_WORK;
				dev->ui.ui_para.washing = 0;
				// root_set_status(SYS_STATUS_NORMAL);
				dev->data.state.run_left_time = 0;
				dev->data.state.dry_left_time = 0;
				dev->data.state.keep_left_time = 0;
				dev->data.state.order_left_time  = 0;
				dev->data.stactl.spe_flag = 2;
				update_data(dev,0);
				init_click_delay(dev);
				#endif
				//send http req
				dev->data.ctl.ctl_state = WASHING_CTL_CANCLE;
				dev_washer_ctl_http(dev);
			}
			else
			debug_d("washer lock on can not cancle/start \n");
				break;
		default:
			break;
	}
	#endif
    return 0;
}

#if 1 //
static void r_btn_event_cb(lv_event_t* event)
{
	dev_washer_t* dev = NULL;
    dev = (dev_washer_t*)lv_event_get_user_data(event);

    switch(event->code){
    case LV_EVENT_RELEASED:
    {
		dev_wh_r_btn_touch_released(event,dev);
		break;
    }
	default:break;
	}
}

#endif

static void btn_gotit_event_cb(lv_event_t *e)
{
	dev_washer_t* dev = NULL;
    dev = (dev_washer_t*)lv_event_get_user_data(e);
    switch(e->code){
	case LV_EVENT_CLICKED:
	{
		// if(dev->data.state.work_state != WASHER_STAT_POWER_OFF
		// || dev->data.state.work_state != WASHER_STAT_STANDBY
		// || dev->data.state.work_state != WASHER_STAT_DRYING
		// || dev->data.state.work_state != WASHER_STAT_KEEPING
		// )
		// {
		// 	dev->data.state.work_state = WASHER_STAT_STANDBY;
		// }
		
		dev->ui.ui_para.ui_stat = wh_ui_stat_invalid;
		update_data(dev,0);
		break;
	}
	case LV_EVENT_LONG_PRESSED_REPEAT:
	{

		break;
	}
    default:
        break;
    }
}

#ifdef TIME_OUT_CHECK
int auto_check_proc(dev_washer_t *dev)
{
    uint16_t time_out = 0xffff;
    switch(dev->data.state.work_state)
    {
        case WASHER_STAT_ORDER:
            time_out = 70;
            break;
        case WASHER_STAT_WORK:
            time_out = 70;
            break;
        case WASHER_STAT_DRYING:
            time_out = 70;
            break;
        case WASHER_STAT_KEEPING:
            time_out = 4200;
            break;
        default:
            break;
    }
    if(++dev->data.stactl.cur_tick >= time_out)
    {
		debug_d("auto check washer state\n");
        // pt_ipc_send_msg(KH_DEV_STATE_AUTO_CHECK,dev->data.base.devid,sizeof(dev->data.base.devid));
        dev->data.stactl.cur_tick = 0;
    }
}
#endif
static void washer_timer_cb(struct _lv_timer_t *t)
{
	static uint16_t tmp_state = 0xff,sec_tick = 0,min_tick = 0;
	dev_washer_t* dev     = NULL;
    dev = (dev_washer_t*)t->user_data;

	//if(DEV_WASHER == kh_dev_type_get())
	{
		if(dev->ui.ui_para.ui_stat == wh_ui_stat_work)
			dev->ui.ui_para.state_tick++;
		if(dev->ui.ui_para.locked)
		{
			if(++dev->ui.ui_para.lock_tick >= WH_CLICK_LOCK_TIME )
			{
				dev->ui.ui_para.locked = 0;
				dev->ui.ui_para.lock_tick = 0;
				debug_d("unlock_btn-----\n");
			}
		}
	}

	if(++sec_tick >= WH_SEC_CNT || dev->data.stactl.update_flag) //1 second
	{
		//debug_d("washer:%s timer---\n",dev->data.base.devid);
		if(dev->data.stactl.update_flag)
		{
			dev->data.stactl.update_flag = 0;
		}
		pt_washer_state(dev);
		sec_tick = 0;
		update_data(dev,1);
		#ifdef TIME_OUT_CHECK
		auto_check_proc(dev);
		#endif

#ifdef WASH_LOOP_TEST
		//static int sec = 0;
		//debug_d("washer timer---------------%d\n",sec++);
		fsm_washer_test(dev);
#endif

	}	


}



int ui_dev_washer_show(dev_washer_t* dev)
{
    if(!dev){
        return -1;
    }

    midea_ui_safe_clear_flag(dev->ui.bg,LV_OBJ_FLAG_HIDDEN);
    midea_ui_safe_clear_flag(dev->ui.bg_img,LV_OBJ_FLAG_HIDDEN);

    // midea_ui_safe_clear_flag(dev->ui.label_info,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_clear_flag(dev->ui.label_info2,LV_OBJ_FLAG_HIDDEN);

	// midea_ui_safe_clear_flag(dev->ui.l_btn,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_clear_flag(dev->ui.l_btn_img,LV_OBJ_FLAG_HIDDEN);
	// midea_ui_safe_clear_flag(dev->ui.r_btn,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_clear_flag(dev->ui.r_btn_img,LV_OBJ_FLAG_HIDDEN);

	//special_stege_show(dev,0);//hide special mode widgets

    //lv_timer_resume(dev->ui.timer);

	//update_ui(dev);

    return 0;
}

int ui_dev_washer_hide(dev_washer_t* dev)
{
    if(!dev){
        return -1;
    }

    midea_ui_safe_add_flag(dev->ui.bg,LV_OBJ_FLAG_HIDDEN);
    midea_ui_safe_add_flag(dev->ui.bg_img,LV_OBJ_FLAG_HIDDEN);

    // midea_ui_safe_add_flag(dev->ui.label_info,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_add_flag(dev->ui.label_info2,LV_OBJ_FLAG_HIDDEN);

	// midea_ui_safe_add_flag(dev->ui.l_btn,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_add_flag(dev->ui.l_btn_img,LV_OBJ_FLAG_HIDDEN);
	// midea_ui_safe_add_flag(dev->ui.r_btn,LV_OBJ_FLAG_HIDDEN);
    // midea_ui_safe_add_flag(dev->ui.r_btn_img,LV_OBJ_FLAG_HIDDEN);

	//special_stege_show(dev,0); //hide special mode widgets
    
	//lv_timer_pause(dev->ui.timer);

    return 0;
}

void init_washer_event(dev_washer_t* dev)
{
	lv_obj_add_event_cb(lv_scr_act(), scr_dev_washer_event_handler, LV_EVENT_GESTURE,(void*)dev);
	lv_obj_add_event_cb(dev->ui.l_btn, l_btn_event_cb, LV_EVENT_ALL, (void*)dev);
	lv_obj_add_event_cb(dev->ui.r_btn, r_btn_event_cb, LV_EVENT_ALL, (void*)dev);
	lv_obj_add_event_cb(dev->ui.btn_gotit,btn_gotit_event_cb,LV_EVENT_ALL, (void*)dev);
}

void remove_washer_event(dev_washer_t *dev)
{
	lv_obj_remove_event_cb(lv_scr_act(), scr_dev_washer_event_handler);
	lv_obj_remove_event_cb(dev->ui.l_btn, l_btn_event_cb);
	lv_obj_remove_event_cb(dev->ui.r_btn, r_btn_event_cb);
	lv_obj_remove_event_cb(dev->ui.btn_gotit,btn_gotit_event_cb);
}

int ui_dev_washer_create(lv_obj_t* parent,void* ui_data)
{
    dev_washer_t* dev   = (dev_washer_t*)ui_data;
    lv_obj_t* superview = parent;
    
    
    lv_coord_t pw = lv_disp_get_hor_res(NULL);
    lv_coord_t ph = lv_disp_get_ver_res(NULL);


    dev->ui.bg  = lv_obj_create(superview);

    lv_obj_set_style_radius(dev->ui.bg, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(dev->ui.bg, 0, LV_PART_MAIN);
    lv_obj_set_style_border_opa(dev->ui.bg, LV_OPA_0, LV_PART_MAIN);
	lv_obj_set_style_border_color(dev->ui.bg, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
    lv_obj_set_style_pad_all(dev->ui.bg,0,0);

	lv_obj_set_style_bg_opa(dev->ui.bg, LV_OPA_0, LV_PART_MAIN);


	lv_obj_set_pos(dev->ui.bg,0,0);
	midea_ui_safe_set_size(dev->ui.bg,pw,ph);
    //****************************************************** */
    dev->ui.bg_img = lv_img_create(superview);
    #if 0
    midea_ui_set_img_src(dwled->ui.bg_img,pt_fs_get("BG_Blue.png"));
    #else
    midea_ui_set_img_src(dev->ui.bg_img,&BG_Blue);
    #endif
    lv_obj_set_pos(dev->ui.bg_img,0,0);
	//////////////////////////////////////////////////////////////
	dev->ui.ui_para.cur_state = 0xff;
	debug_d("cur_state init:%02x\n");
	#if 1
 //Write codes scr_dev_washer_label_info
	dev->ui.label_info = lv_label_create(superview);
	midea_ui_safe_set_text(dev->ui.label_info, "待机中");
	lv_label_set_long_mode(dev->ui.label_info, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.label_info, 94, 85);
	midea_ui_safe_set_size(dev->ui.label_info, 264, 70);

	//Write style for scr_dev_washer_label_info, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.label_info, lv_color_hex(0xeeeeee), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.label_info, lv_font_get(60), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.label_info, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.label_info, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.label_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_washer_label_info2
	dev->ui.label_info2 = lv_label_create(superview);////
	midea_ui_safe_set_text(dev->ui.label_info2, "");
	lv_label_set_long_mode(dev->ui.label_info2, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.label_info2, 85, 163);
	midea_ui_safe_set_size(dev->ui.label_info2, 280, 24);

	//Write style for scr_dev_washer_label_info2, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.label_info2, lv_color_hex(0x8a8a8a), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.label_info2, lv_font_get(20), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.label_info2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.label_info2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.label_info2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	dev->ui.l_btn = lv_obj_create(superview);

    lv_obj_set_pos(dev->ui.l_btn,80,195);
    midea_ui_safe_set_size(dev->ui.l_btn,86,86);

	lv_obj_set_style_radius(dev->ui.l_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(dev->ui.l_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(dev->ui.l_btn, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(dev->ui.l_btn, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(dev->ui.l_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(dev->ui.l_btn, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(dev->ui.l_btn, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(dev->ui.l_btn, 0,0);

    #if 1
    lv_obj_set_style_bg_opa(dev->ui.l_btn,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(dev->ui.l_btn,LV_OPA_100,0);
    lv_obj_set_style_bg_color(dev->ui.l_btn,lv_color_make(0xff,0,0),0);
    #endif
	dev->ui.l_btn_img = lv_img_create(dev->ui.l_btn);
    midea_ui_set_img_src(dev->ui.l_btn_img,pt_fs_get(icon_stat[0]));
    lv_obj_set_pos(dev->ui.l_btn_img,0,0);

	dev->ui.r_btn = lv_obj_create(superview);

    lv_obj_set_pos(dev->ui.r_btn,286,195);
    midea_ui_safe_set_size(dev->ui.r_btn,86,86);

	lv_obj_set_style_radius(dev->ui.r_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(dev->ui.r_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(dev->ui.r_btn, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(dev->ui.r_btn, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(dev->ui.r_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(dev->ui.r_btn, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(dev->ui.r_btn, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(dev->ui.r_btn, 0,0);

    #if 1
    lv_obj_set_style_bg_opa(dev->ui.r_btn,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(dev->ui.r_btn,LV_OPA_100,0);
    lv_obj_set_style_bg_color(dev->ui.r_btn,lv_color_make(0xff,0,0),0);
    #endif

	dev->ui.r_btn_img = lv_img_create(dev->ui.r_btn);
    midea_ui_set_img_src(dev->ui.r_btn_img,pt_fs_get(icon_stat[4]));
    lv_obj_set_pos(dev->ui.r_btn_img,0,0);
	#endif


	//speical mode////////////////////////////////////////////////////////////////
	//scr_dev_heater_cont_spec_mode
	#if 1
	dev->ui.cont_spec_mode = lv_obj_create(superview);
	lv_obj_set_pos(dev->ui.cont_spec_mode, 30, 80);
	midea_ui_safe_set_size(dev->ui.cont_spec_mode, 420, 160);
	//lv_obj_set_scrollbar_mode(dev->ui.cont_spec_mode, LV_SCROLLBAR_MODE_OFF);
	//midea_ui_safe_add_flag(dev->ui.cont_spec_mode, LV_OBJ_FLAG_HIDDEN);

	//Wscr_dev_heater_cont_spec_mode, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.cont_spec_mode, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_heater_lbl_info
	dev->ui.lbl_info = lv_label_create(dev->ui.cont_spec_mode);
	midea_ui_safe_set_text(dev->ui.lbl_info, "洗涤中 | 剩余时长");
	lv_label_set_long_mode(dev->ui.lbl_info, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.lbl_info, 80, 10);
	midea_ui_safe_set_size(dev->ui.lbl_info, 260, 28);

	//Write style for scr_dev_heater_lbl_info, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.lbl_info, lv_color_hex(0x8a8a8a), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.lbl_info, lv_font_get(20), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.lbl_info, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.lbl_info, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.lbl_info, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_heater_lbl_unit1
	dev->ui.lbl_unit1 = lv_label_create(dev->ui.cont_spec_mode);
	midea_ui_safe_set_text(dev->ui.lbl_unit1, "时\n");
	lv_label_set_long_mode(dev->ui.lbl_unit1, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.lbl_unit1, 150, 118);
	midea_ui_safe_set_size(dev->ui.lbl_unit1, 55, 22);

	//Write style for scr_dev_heater_lbl_unit1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_radius(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_border_width(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.lbl_unit1, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.lbl_unit1, lv_font_get(24), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.lbl_unit1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.lbl_unit1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.lbl_unit1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	midea_ui_safe_add_flag(dev->ui.lbl_unit1, LV_OBJ_FLAG_HIDDEN);//hide

		//Write codes scr_dev_heater_lbl_unit1
	dev->ui.lbl_unit2 = lv_label_create(dev->ui.cont_spec_mode);
	midea_ui_safe_set_text(dev->ui.lbl_unit2, "分\n");
	lv_label_set_long_mode(dev->ui.lbl_unit2, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.lbl_unit2, 304, 118);
	midea_ui_safe_set_size(dev->ui.lbl_unit2, 55, 22);

	//Write style for lbl_unit2, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_radius(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_border_width(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.lbl_unit2, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.lbl_unit2, lv_font_get(24), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.lbl_unit2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.lbl_unit2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.lbl_unit2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	midea_ui_safe_add_flag(dev->ui.lbl_unit2, LV_OBJ_FLAG_HIDDEN);//hide

	//Write codes scr_dev_heater_lbl_data1
	dev->ui.lbl_data1 = lv_label_create(dev->ui.cont_spec_mode);
	midea_ui_safe_set_text(dev->ui.lbl_data1, " \n");
	lv_label_set_long_mode(dev->ui.lbl_data1, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.lbl_data1, 68, 52);
	midea_ui_safe_set_size(dev->ui.lbl_data1, 150, 97);

	//Write style for scr_dev_heater_lbl_data1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.lbl_data1, lv_color_hex(0xeeeeee), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.lbl_data1, lv_font_get(90), LV_PART_MAIN|LV_STATE_DEFAULT);//100->70
	lv_obj_set_style_text_opa(dev->ui.lbl_data1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.lbl_data1, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.lbl_data1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	midea_ui_safe_add_flag(dev->ui.lbl_data1, LV_OBJ_FLAG_HIDDEN);//hide

	//Write codes scr_dev_heater_lbl_data2
	dev->ui.lbl_data2 = lv_label_create(dev->ui.cont_spec_mode);
	midea_ui_safe_set_text(dev->ui.lbl_data2, " \n");
	lv_label_set_long_mode(dev->ui.lbl_data2, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.lbl_data2, 68, 52);
	midea_ui_safe_set_size(dev->ui.lbl_data2, 150, 97);

	//Write style for scr_dev_heater_lbl_data2, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.lbl_data2, lv_color_hex(0xeeeeee), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.lbl_data2, lv_font_get(90), LV_PART_MAIN|LV_STATE_DEFAULT);//100->70
	lv_obj_set_style_text_opa(dev->ui.lbl_data2, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.lbl_data2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.lbl_data2, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	midea_ui_safe_add_flag(dev->ui.lbl_data2, LV_OBJ_FLAG_HIDDEN);//hide

	//Write codes bar_1
	dev->ui.bar_1 = lv_bar_create(superview);
	lv_obj_set_style_anim_time(dev->ui.bar_1, 1000, 0);
	lv_bar_set_mode(dev->ui.bar_1, LV_BAR_MODE_NORMAL);
	lv_bar_set_range(dev->ui.bar_1, 0, 100);
	lv_bar_set_value(dev->ui.bar_1, 0, LV_ANIM_OFF);
	lv_obj_set_pos(dev->ui.bar_1, 0, 289);
	midea_ui_safe_set_size(dev->ui.bar_1, 477, 31);
	//midea_ui_safe_add_flag(dev->ui.bar_1, LV_OBJ_FLAG_HIDDEN);

	//Write style for bar_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_radius(dev->ui.bar_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.bar_1, 129, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(dev->ui.bar_1, lv_color_hex(0x000000), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_grad_dir(dev->ui.bar_1, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.bar_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write style for bar_1, Part: LV_PART_INDICATOR, State: LV_STATE_DEFAULT. //0xFF8225
	lv_obj_set_style_radius(dev->ui.bar_1, 0, LV_PART_INDICATOR|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.bar_1, 255, LV_PART_INDICATOR|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(dev->ui.bar_1, lv_color_hex(0x081025), LV_PART_INDICATOR|LV_STATE_DEFAULT); // 0x0A2145
	lv_obj_set_style_bg_grad_dir(dev->ui.bar_1, LV_GRAD_DIR_HOR, LV_PART_INDICATOR|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_grad_color(dev->ui.bar_1, lv_color_hex(0x267AFF), LV_PART_INDICATOR|LV_STATE_DEFAULT); //0x226EE6
	lv_obj_set_style_bg_main_stop(dev->ui.bar_1, 0, LV_PART_INDICATOR|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_grad_stop(dev->ui.bar_1, 255, LV_PART_INDICATOR|LV_STATE_DEFAULT);
	#endif

	//special mode dialog////////////////////////
	#if 1
	//Write codes scr_dev_washer_cont_dialog
	dev->ui.cont_dialog = lv_obj_create(superview);
	lv_obj_set_pos(dev->ui.cont_dialog, 40, 51);
	midea_ui_safe_set_size(dev->ui.cont_dialog, 405, 261);

	
	//lv_obj_set_scrollbar_mode(dev->ui.cont_dialog, LV_SCROLLBAR_MODE_OFF);
	//midea_ui_safe_add_flag(dev->ui.cont_dialog, LV_OBJ_FLAG_HIDDEN);

	//Write style for scr_dev_washer_cont_dialog, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.cont_dialog, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_washer_btn_gotit
	dev->ui.btn_gotit = lv_btn_create(dev->ui.cont_dialog);
	dev->ui.btn_gotit_label = lv_label_create(dev->ui.btn_gotit);
	midea_ui_safe_set_text(dev->ui.btn_gotit_label, "知道了 (   S)");
	lv_label_set_long_mode(dev->ui.btn_gotit_label, LV_LABEL_LONG_WRAP);
	midea_ui_safe_obj_align(dev->ui.btn_gotit_label, LV_ALIGN_CENTER, 0, 0);
	lv_obj_set_style_pad_all(dev->ui.btn_gotit, 0, LV_STATE_DEFAULT);
	lv_obj_set_width(dev->ui.btn_gotit_label, LV_PCT(100));
	lv_obj_set_pos(dev->ui.btn_gotit, 43, 207);
	midea_ui_safe_set_size(dev->ui.btn_gotit, 317, 42);

	//Write style for scr_dev_washer_btn_gotit, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.btn_gotit, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.btn_gotit, 21, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.btn_gotit, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.btn_gotit, lv_font_get(20), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.btn_gotit, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.btn_gotit, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.btn_gotit, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(dev->ui.btn_gotit, lv_color_hex(0x1e7cff), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_grad_dir(dev->ui.btn_gotit, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.btn_gotit, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_heater_img_ok
	dev->ui.img_ok = lv_img_create(dev->ui.cont_dialog);
	midea_ui_safe_add_flag(dev->ui.img_ok, LV_OBJ_FLAG_CLICKABLE);
	midea_ui_set_img_src(dev->ui.img_ok, pt_fs_get("Succeed.png"));
	lv_img_set_pivot(dev->ui.img_ok, 50,50);
	lv_img_set_angle(dev->ui.img_ok, 0);
	lv_obj_set_pos(dev->ui.img_ok, 159, 2); //154
	midea_ui_safe_set_size(dev->ui.img_ok, 79, 79);

	//Write style for scr_dev_heater_img_ok, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_radius(dev->ui.img_ok, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_clip_corner(dev->ui.img_ok, true, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_img_recolor_opa(dev->ui.img_ok, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_img_opa(dev->ui.img_ok, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_heater_label_note
	dev->ui.label_note = lv_label_create(dev->ui.cont_dialog);
	midea_ui_safe_set_text(dev->ui.label_note, "洗碗机已完成洗涤");
	lv_label_set_long_mode(dev->ui.label_note, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.label_note, 52, 116);
	midea_ui_safe_set_size(dev->ui.label_note, 309, 33);

	//Write style for scr_dev_heater_label_note, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.label_note, lv_color_hex(0xe2e2e2), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.label_note, lv_font_get(20), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.label_note, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.label_note, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.label_note, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

	//Write codes scr_dev_heater_label_sec
	dev->ui.label_sec = lv_label_create(dev->ui.cont_dialog);
	midea_ui_safe_set_text(dev->ui.label_sec, "10");
	lv_label_set_long_mode(dev->ui.label_sec, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(dev->ui.label_sec, 213, 216);
	midea_ui_safe_set_size(dev->ui.label_sec, 30, 32);

	//Write style for scr_dev_heater_label_sec, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_border_width(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_radius(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_color(dev->ui.label_sec, lv_color_hex(0xfbfbfb), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_font(dev->ui.label_sec, lv_font_get(20), LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_opa(dev->ui.label_sec, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_letter_space(dev->ui.label_sec, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_line_space(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_text_align(dev->ui.label_sec, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_opa(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_top(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_right(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_bottom(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_pad_left(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_shadow_width(dev->ui.label_sec, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
	#endif

	//

	init_washer_event(dev);
	debug_d("reg l and r btn-------\n");
	//special_stege_show(dev,0);
	//update_ui(dev);
	//washer_stat_proc(dev);
    
    return 0;
}

int ui_dev_washer_destroy(void* ui_data)
{
    dev_washer_t* dev  = (dev_washer_t*)ui_data;

    if(!dev){
        return -1;
    }

	//remove_washer_timer(dev);

	remove_washer_event(dev);
	#if 1
	printf("del washer timer--------------\n");
	if(dev->ui.label_info){
        midea_ui_safe_del_obj(dev->ui.label_info);
        dev->ui.label_info = NULL;
    }

	if(dev->ui.bg_img){
        midea_ui_safe_del_obj(dev->ui.bg_img);
        dev->ui.bg_img = NULL;
	}

	if(dev->ui.bg){
        midea_ui_safe_del_obj(dev->ui.bg);
        dev->ui.bg = NULL;
    }

    if(dev->ui.label_info2){
        midea_ui_safe_del_obj(dev->ui.label_info2);
        dev->ui.label_info2 = NULL;
    }
	if(dev->ui.l_btn_img){
		midea_ui_safe_del_obj(dev->ui.l_btn_img);
        dev->ui.l_btn_img = NULL;
    }
    if(dev->ui.l_btn){
        midea_ui_safe_del_obj(dev->ui.l_btn);
        dev->ui.l_btn = NULL;
    }
    if(dev->ui.r_btn_img){
		midea_ui_safe_del_obj(dev->ui.r_btn_img);
        dev->ui.r_btn_img = NULL;
    }
	    if(dev->ui.r_btn){
        midea_ui_safe_del_obj(dev->ui.r_btn);
        dev->ui.r_btn = NULL;
    }

	//special mode
    if(dev->ui.lbl_info){
        midea_ui_safe_del_obj(dev->ui.lbl_info);
        dev->ui.lbl_info = NULL;
	}
	if(dev->ui.lbl_unit1){
        midea_ui_safe_del_obj(dev->ui.lbl_unit1);
        dev->ui.lbl_unit1 = NULL;
    }

    if(dev->ui.lbl_unit2){
        midea_ui_safe_del_obj(dev->ui.lbl_unit2);
        dev->ui.lbl_unit2 = NULL;
    }
    if(dev->ui.lbl_data1){
        midea_ui_safe_del_obj(dev->ui.lbl_data1);
        dev->ui.lbl_data1 = NULL;
    }
    if(dev->ui.lbl_data2){
        midea_ui_safe_del_obj(dev->ui.lbl_data2);
        dev->ui.lbl_data2 = NULL;
    }
    if(dev->ui.cont_spec_mode){
        midea_ui_safe_del_obj(dev->ui.cont_spec_mode);
        dev->ui.cont_spec_mode = NULL;
    }

	if(dev->ui.btn_gotit_label){
        midea_ui_safe_del_obj(dev->ui.btn_gotit_label);
        dev->ui.btn_gotit_label = NULL;
    }

    if(dev->ui.btn_gotit){
        midea_ui_safe_del_obj(dev->ui.btn_gotit);
        dev->ui.btn_gotit = NULL;
    }

    if(dev->ui.img_ok){
        midea_ui_safe_del_obj(dev->ui.img_ok);
        dev->ui.img_ok = NULL;
    }
    if(dev->ui.label_note){
        midea_ui_safe_del_obj(dev->ui.label_note);
        dev->ui.label_note = NULL;
    }
    if(dev->ui.label_sec){
        midea_ui_safe_del_obj(dev->ui.label_sec);
        dev->ui.label_sec = NULL;
    }

    if(dev->ui.cont_dialog){
        midea_ui_safe_del_obj(dev->ui.cont_dialog);
        dev->ui.cont_dialog = NULL;
    }
    if(dev->ui.bar_1){
        midea_ui_safe_del_obj(dev->ui.bar_1);
        dev->ui.bar_1 = NULL;
    }
	#endif


	return 0;
}

void create_washer_timer(dev_washer_t* dev)
{
	if(dev->ui.timer == NULL)
	{
		debug_d("%s create washer timer\n",dev->data.base.devid);
		dev->ui.timer = lv_timer_create(washer_timer_cb, TIMER_FREQ, (void*)dev);
	}
	debug_d("resume washer timer\n");
	//lv_timer_resume(dev->ui.timer);
	lv_timer_reset(dev->ui.timer);
		
}

void remove_washer_timer(dev_washer_t* dev)
{
	if(dev->ui.timer){
        midea_ui_safe_del_timer(dev->ui.timer);
        dev->ui.timer = NULL;
    }
}

void washer_pwr_on_click(lv_event_t* event,dev_washer_t* dev)
{
	dev->ui.ui_para.tick = 0;

	lv_area_t   t_area;
    lv_point_t  lv_point;
    lv_indev_t* indev  = NULL;
    lv_obj_t*   target = NULL;

    target = lv_event_get_target(event);
    if(!target){
        debug_e("err\n");
        return -1;
    }

    indev = lv_indev_get_act();
    if(!indev){
        return -1;
    }

    lv_indev_get_point(indev, &lv_point);
    lv_obj_get_coords(target, &t_area);

    if(!is_touch_in_target(&lv_point,&t_area)){
        debug_e("out range\n");
        return -1;
    }

	if(!pt_network_get()){
		debug_e("net err\n");
        return -1;
	}

	// if(dev->ui.ui_para.locked)
	// {
	// 	debug_d("pwroff_btn invalid:%d\n",dev->ui.ui_para.lock_tick);
	// 	return -1;
	// }
	debug_d("---------washer_pwr_on_click\n");
	#ifdef PROACTIVELY_UPDATE_UI
	dev->data.state.work_state = WASHER_STAT_STANDBY;
	dev->data.state.status = DEV_WORK;
	//ui_dev_washer_show(dev);
	update_data(dev,0);
	//lv_timer_resume(dev->ui.timer);
	//ui_dev_off_hide(&dev->ui.dev_off);
	//ui_dev_off_line_hide(&dev->ui.dev_off_line);
	init_click_delay(dev);
	#endif

	//send http req
	dev->data.ctl.ctl_state = WASHING_CTL_POWER_ON;
	dev_washer_ctl_http(dev);
}

static int ui_washer_create(lv_obj_t* parent,void* ui_data)
{
    dev_washer_t* dev   = (dev_washer_t*)ui_data;
    lv_obj_t* superview = parent;

	// kh_dev_type_set(DEV_WASHER);
	#ifdef PROACTIVELY_UPDATE_UI
	dev->data.stactl.got_data = 0;
	#endif
	//dev->data.stactl.auto_tick = 0;
	dev->ui.ui_para.locked = 0;
	dev->ui.ui_para.lock_tick = 0;
	dev->ui.ui_para.tick = 0;
	dev->ui.ui_para.ui_last_stat = wh_ui_stat_invalid;
	dev->ui.ui_para.ui_stat = wh_ui_stat_invalid;
	// pt_ipc_send_msg(KH_DEV_STATE_AUTO_CHECK,dev->data.base.devid,sizeof(dev->data.base.devid));

    ui_dev_washer_create(parent,ui_data);
    ui_dev_off_create(superview,&dev->ui.dev_off);
    ui_dev_off_line_create(superview,&dev->ui.dev_off_line);
	#ifdef USE_ERR_PAGE
	ui_dev_err_e2_create(superview,&dev->ui.dev_e2);
	#endif
	create_washer_timer(dev);
	debug_d("-----------in wh page:state:%d,work_state:%d,door:%d\n"
        ,dev->data.state.status,dev->data.state.work_state,dev->data.state.door_state);

	update_data(dev,0);
 
    return 0;
}

static int ui_washer_destroy(void* ui_data)
{
	dev_washer_t* dev = (dev_washer_t*)ui_data;

	// kh_dev_type_set(DEV_INVALID);
    
	remove_washer_timer(dev);
    ui_dev_off_destroy(&dev->ui.dev_off);
    ui_dev_off_line_destroy(&dev->ui.dev_off_line);
	#ifdef USE_ERR_PAGE
	ui_dev_err_e2_destroy(&dev->ui.dev_e2);
	#endif

    ui_dev_washer_destroy(ui_data);

    return 0;
}

static void on_custom_attr_config(page_base_t* self)
{
}
static void on_view_load(page_base_t* self)
{

}
static void on_view_did_load(page_base_t* self)
{
   
}
static void on_view_will_appear(page_base_t* self)
{

}
static void on_view_did_appear(page_base_t* self)
{

}
static void on_view_will_disappear(page_base_t* self)
{

}
static void on_view_did_disappear(page_base_t* self)
{

}
static void on_view_did_unload(page_base_t* self)
{
	ui_washer_destroy(self);
}


dev_info_t* dev_washer_reg(data_washer_t* dev)
{
    int len = 0;
    dev_washer_t*    dev_wh   = NULL;
    page_vtable_t*  method   = NULL;
    dev_info_t*     devinfo  = NULL;

    if(!dev){
        return NULL;
    }

    devinfo = (dev_info_t*)malloc(sizeof(dev_info_t));
    if(!devinfo){
        debug_d("merr\n");
        return NULL;
    }

    dev_wh = (dev_washer_t*)malloc(sizeof(dev_washer_t));
    if(!dev_wh){
        debug_d("merr\n");
        return NULL;
    }
    memset(dev_wh,0,sizeof(dev_washer_t));

    method = (page_vtable_t*)malloc(sizeof(page_vtable_t));
    if(!method){
        debug_d("merr\n");
        return NULL;
    }

    //***********************************************************
    method->on_custom_attr_config  = on_custom_attr_config;
    method->on_view_load           = on_view_load;
    method->on_view_did_load       = on_view_did_load;
    method->on_view_will_appear    = on_view_will_appear;
    method->on_view_did_appear     = on_view_did_appear;
    method->on_view_will_disappear = on_view_will_disappear;
    method->on_view_did_disappear  = on_view_did_disappear;
    method->on_view_did_unload     = on_view_did_unload;
    //***********************************************************
    memcpy(&dev_wh->data,dev,sizeof(data_washer_t));
    //***********************************************************
    devinfo->method     = method;    
    devinfo->priv_data  = (void*)dev_wh;
    //***********************************************************
	//pwh = dev_wh;
	dev_wh->ui.dev_off.dev = dev_wh;
	dev_wh->ui.dev_off.pwr_on_cb = washer_pwr_on_click;
    return devinfo;
}

int dev_washer_unreg(dev_info_t* devinfo)
{
    


    return 0;
}

static void dev_washer_on_page_create(lv_obj_t* parent,void* ui_data)
{
    debug_d("washer create\n");
	ui_washer_create(parent,ui_data);
}
static void dev_washer_on_page_destroy(void* ui_data)
{
    debug_d("washer destroy\n");
	ui_washer_destroy(ui_data);

}
static void dev_washer_on_page_update(void* ui_data)
{

}
page_info_t* dev_washer_page_reg(dev_washer_t* washer)
{
    page_method_t*  method  = NULL;
    page_info_t*    page    = NULL;

    page = (page_info_t*)malloc(sizeof(page_info_t));
    if(!page){
        debug_e("err0\n");
        return NULL;
    }
    method = (page_method_t*)malloc(sizeof(page_method_t));
    if(!method){
        debug_e("err1\n");
        return NULL;
    }
    //***********************************************************
    method->on_page_create  = dev_washer_on_page_create;
    method->on_page_destroy = dev_washer_on_page_destroy;
    method->on_page_update  = dev_washer_on_page_update;
    //***********************************************************
    page->method  = method;    
    page->data    = (void*)washer;
    //***********************************************************

    return page;
}



#ifdef WASH_LOOP_TEST
static int test_step = 0;
static int loop_tick = 0;
static int loop_tick2 = 0;
static int loop_tick3 = 0;
void rst_test_loop(dev_washer_t* dev)
{
	test_step = 0;
	loop_tick = 0;
	loop_tick2 = 0;
	loop_tick3 = 0;
	#if 0
	dev->data.state.work_state = WASHER_STAT_STANDBY;
	dev->data.state.status = DEV_WORK;
	#else
	dev->data.state.work_state = WASHER_STAT_POWER_OFF;
	dev->data.state.status = DEV_OFF;
	#endif
}
#define WASH_TOTAL_TIME 30
void fsm_washer_test(dev_washer_t* dev)
{

	static int wash_step_time = 5 ;
	static int standby_time = 10;
	static int pwr_off_time = 10;
	switch(test_step)
	{
		case 0:
			rst_test_loop(dev);
			test_step++;
			break;
		case 2:
			if(loop_tick3++ > 20)
			{
				test_step = 0;
			}
			break;
		default:
			break;
	}
    loop_tick++;
	//l_d("in_2: dev_state:%d,work_state:%d---\n",pt_washer_status_get(),dev->data.work_state);
    switch(dev->data.state.status)
    {
        case DEV_OFF:
			if(loop_tick++ > pwr_off_time)
			{
				dev->data.state.work_state = WASHER_STAT_STANDBY;
				dev->data.state.status = DEV_WORK;
				loop_tick = 0;
			}
        	break;

        case DEV_OFF_LINE:
        break;
        case DEV_WORK:
            switch(dev->data.state.work_state)
            {

                case WASHER_STAT_STANDBY://待机
					if(loop_tick++ > standby_time)
					{
						loop_tick = 0;
						dev->data.state.work_state = WASHER_STAT_ORDER;
						dev->data.state.order_left_time = 10;
						debug_d("fsm_washer_test-> WASHER_STAT_ORDER order left time:%d\n",dev->data.state.order_left_time);
					}
                    break;
                case WASHER_STAT_ORDER:////预约中
					//dev->data.state.order_left_time--;
					if(dev->data.state.order_left_time <= 0)
					{
						dev->data.state.work_state = WASHER_STAT_WORK;
						dev->data.state.run_left_time = WASH_TOTAL_TIME; //167
						dev->ui.ui_para.init_work_time = dev->data.state.run_left_time;
						dev->data.state.wash_stage = 1;
						wash_step_time = dev->ui.ui_para.init_work_time / 5;
						debug_d("fsm_washer_test-> WASHER_STAT_WORK run left time:%d\n",dev->data.state.run_left_time);
						loop_tick2 = 0;
					}
                    break;
                case WASHER_STAT_WORK://洗涤中
					//dev->data.state.run_left_time--;
					if(loop_tick2++ > wash_step_time)
					{
						if(dev->data.state.wash_stage  < 5)
							dev->data.state.wash_stage ++;
						loop_tick2 = 0;
					}
					if(dev->data.state.run_left_time <= 0)
					{
						dev->data.state.work_state = WASHER_STAT_DRYING;
						dev->data.state.dry_left_time = 10;
						debug_d("fsm_washer_test-> WASHER_STAT_DRYING dry left time:%d\n",dev->data.state.dry_left_time);
					}
                    break;
                case WASHER_STAT_DRYING:////烘干中
					//dev->data.state.dry_left_time--;
					if(dev->data.state.dry_left_time <= 0)
					{
						dev->data.state.work_state = WASHER_STAT_KEEPING;
						dev->data.state.keep_left_time = 10;
						debug_d("fsm_washer_test-> WASHER_STAT_KEEPING keep left time:%d\n",dev->data.state.keep_left_time);
					}
                    break;
                case WASHER_STAT_KEEPING://保管中,
					if(dev->data.state.keep_left_time > 0)
					{
						//dev->data.state.keep_left_time--;
					}
					else
					{
						//test_step = 0; //
						dev->data.state.work_state = WASHER_STAT_STANDBY;
						//rst_test_loop(dev);
						standby_time = 100;
					}

                    break;
                case WASHER_STAT_PAUSE://
                    break;
                case WASHER_STAT_ERROR://故障中
                    break;
				case WASHER_STAT_OFFLINE:
					break;
                default:
                    break;

            }
        break;
        default:
        break;
    }

}

#endif
